home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap17 / dun17_3.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  2.5 KB  |  101 lines

  1. <HTML>
  2. <HEAD>
  3.   <TITLE>Routing Events With routeEvent()</TITLE>
  4.  
  5.   <STYLE>
  6.     #banner         { font-family: arial, helvetica, sans-serif;
  7.                       font-size: 18pt; }
  8.   </STYLE>
  9.  
  10.   <SCRIPT>
  11.     eventText = "";
  12.     capturingObject = "";
  13.  
  14.     function displayEvent(event)
  15.     {
  16.       eventText += capturingObject + " ---> ";
  17.  
  18.       if (event.target.constructor == Layer)
  19.         resultLayer = document.layerResults;
  20.       else
  21.         resultLayer = document.linkResults;
  22.  
  23.       resultLayer.document.writeln("<P><TT>");
  24.       resultLayer.document.writeln(eventText);
  25.       resultLayer.document.writeln("</TT></P>");
  26.       resultLayer.document.close();
  27.     }
  28.  
  29.     function handleWindow(event)
  30.     {
  31.       eventText = "";
  32.       capturingObject = "window";
  33.       displayEvent(event);
  34.       return routeEvent(event);
  35.     }
  36.  
  37.     function handleDocument(event)
  38.     {
  39.       capturingObject = "document";
  40.       displayEvent(event);
  41.       return routeEvent(event);
  42.     }
  43.  
  44.     function handleLayer(event)
  45.     {
  46.       capturingObject = "layer";
  47.       displayEvent(event);
  48.     }
  49.  
  50.     function handleLink(event)
  51.     {
  52.       capturingObject = "link";
  53.       displayEvent(event);
  54.     }
  55.  
  56.     function initialize()
  57.     {
  58.       window.captureEvents(Event.MOUSEOVER);
  59.       window.onmouseover = handleWindow;
  60.       document.captureEvents(Event.MOUSEOVER);
  61.       document.onmouseover = handleDocument;
  62.     }
  63.   </SCRIPT>
  64.  
  65. </HEAD>
  66.  
  67.  
  68. <BODY onLoad="initialize();">
  69.  
  70. <LAYER ID=banner onMouseOver="handleLayer(event);">
  71.   <A HREF="home.html" onMouseOver="handleLink(event);">
  72.     <IMG SRC="arrow.gif" ALIGN=left>
  73.   </A>
  74.  
  75.   Routing Events With <TT>routeEvent()</TT>
  76. </LAYER>
  77.  
  78. <BR><BR>
  79. <BLOCKQUOTE>
  80. <P>By passing the mouse over the title banner, a <TT>mouseOver<TT>
  81. event is generated which is captured by the window and document
  82. objects before being passed to the layer object.  If the mouse is
  83. passed over the arrow link, the <TT>mouseOver</TT> event is also
  84. captured by the window and document objects before reaching the
  85. link object.</P>
  86.  
  87. <P>The following is the event path for a <TT>mouseOver</TT> event
  88. directed at the image link element:</P>
  89.  
  90. <LAYER ID=linkResults></LAYER>
  91.  
  92. <BR><BR>
  93. <P>And the following is the event path for a <TT>mouseOver</TT> event
  94. directed at the banner layer:</P>
  95.  
  96. <LAYER ID=layerResults></LAYER>
  97. </BLOCKQUOTE>
  98.  
  99. </BODY>
  100. </HTML>
  101.